<?php
namespace app\controller;

use app\model\AdminModel;
use core\lib\Language;
use core\lib\Request;
use models\Base64Image;

class IndexController extends \core\lib\CController
{

    public function beforeAction(){
        return true;
    }

    /**
     * 接受图片上传
     */
    public function uploadImgs(){
        $base64Image = new Base64Image();
        $imgUrl = $base64Image->move_image('data','merchant/images');
        $request = new Request();
        if($imgUrl){
            $url = (string) $request->getHost() ."/".$imgUrl;
            echo '{"result":"1","msg":"上传成功","imgSrc":"'.$url.'","relativePath":"'.$imgUrl.'"}';
        }else{
            echo '{"result":"404","msg":"上传失败","imgSrc":"","relativePath":""}';
        }
    }


    public function index()
    {
        //echo $_GET['id'];
        $model = new AdminModel();
        $rs = $model->lists();
        dump($rs);

        //$data = $rs;
        $this->assign('data', $data= array());
        $this->display('index.html');

    }

    public function testIndex(){
        $model = new AdminModel();
        dump($_SERVER);
        //dump(Language::all('db/testdb'));
        $this->display('sjWeb1.php');
    }
}